package demo;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:用scanner来读取
 * User: rei
 * Date: 2025-11-26
 * Time: 18:41
 */
public class FileInputStream_test {
    public static void main(String[] args) throws IOException {
        FileInputStream input = new FileInputStream("c:/temp/123.txt");
        //借助scanner来简化数据读取操作
        Scanner sc = new Scanner(input, "UTF-8");
        while(true){
            //如果没有下一行了,就结束
            if (!sc.hasNextLine()){
                break;
            }
            String line = sc.nextLine();
            System.out.println(line );
        }
        sc.close();
        input.close();
    }
}
